home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form RecipMnt
- BackColor = &H00E0FFFF&
- Caption = "Recipe File Maintenance"
- Height = 4905
- Icon = RECIPMNT.FRX:0000
- Left = 210
- LinkMode = 1 'Source
- LinkTopic = "RecipMnt"
- MaxButton = 0 'False
- MDIChild = -1 'True
- ScaleHeight = 4500
- ScaleWidth = 9015
- Top = 1200
- Width = 9135
- Begin CommandButton CmdRemove
- Caption = "Remo&ve Ingredient"
- Height = 375
- Left = 6960
- TabIndex = 33
- Top = 3960
- Width = 1695
- End
- Begin CommandButton CmdClose
- Caption = "&Close"
- Height = 375
- Left = 5160
- TabIndex = 32
- Top = 3960
- Width = 855
- End
- Begin CommandButton CmdCancel
- Cancel = -1 'True
- Caption = "Cancel"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 4320
- TabIndex = 31
- Top = 3960
- Width = 855
- End
- Begin CommandButton CmdDelete
- Caption = "&Delete"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 3360
- TabIndex = 30
- Top = 3960
- Width = 855
- End
- Begin CommandButton CmdUpdate
- Caption = "&Update"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 2520
- TabIndex = 29
- Top = 3960
- Width = 855
- End
- Begin CommandButton CmdAdd
- Caption = "&Add"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 1680
- TabIndex = 28
- Top = 3960
- Width = 855
- End
- Begin CommandButton CmdNext
- BackColor = &H00FFFFFF&
- Caption = "&Next"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 840
- TabIndex = 27
- TabStop = 0 'False
- Top = 3960
- Width = 735
- End
- Begin CommandButton CmdPrevious
- Caption = "&Previous"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 120
- TabIndex = 26
- TabStop = 0 'False
- Top = 3960
- Width = 735
- End
- Begin Grid Grid1
- Cols = 5
- Enabled = 0 'False
- FixedCols = 0
- FixedRows = 0
- Height = 1455
- Left = 120
- ScrollBars = 0 'None
- TabIndex = 22
- Top = 1920
- Width = 8535
- End
- Begin TextBox TxtUnits
- Height = 375
- Left = 5520
- TabIndex = 19
- Top = 1440
- Width = 975
- End
- Begin TextBox TxtIngKey
- Height = 375
- Left = 120
- TabIndex = 17
- Top = 1440
- Width = 2175
- End
- Begin TextBox TxtLife
- Height = 375
- Left = 7920
- TabIndex = 15
- Top = 600
- Width = 735
- End
- Begin TextBox TxtMaintCode
- Height = 375
- Left = 6240
- TabIndex = 13
- Top = 600
- Width = 735
- End
- Begin TextBox TxtTarget
- Height = 375
- Left = 4200
- TabIndex = 11
- Top = 600
- Width = 735
- End
- Begin TextBox TxtYields
- Height = 375
- Left = 2520
- TabIndex = 9
- Top = 600
- Width = 615
- End
- Begin TextBox TxtRetail
- Height = 375
- Left = 840
- TabIndex = 7
- Top = 600
- Width = 855
- End
- Begin TextBox TxtGroup
- Height = 375
- Left = 7920
- TabIndex = 5
- Top = 120
- Width = 735
- End
- Begin TextBox TxtDesc
- Height = 375
- Left = 3480
- TabIndex = 3
- Top = 120
- Width = 3495
- End
- Begin TextBox TxtKey
- Height = 375
- Left = 1320
- TabIndex = 1
- Top = 120
- Width = 855
- End
- Begin Line Line2
- X1 = 120
- X2 = 8760
- Y1 = 3480
- Y2 = 3480
- End
- Begin Line Line1
- X1 = 120
- X2 = 8760
- Y1 = 1080
- Y2 = 1080
- End
- Begin Label LblProfitMargin
- BackColor = &H00E0FFFF&
- Caption = "Profit Margin = "
- Height = 255
- Left = 5760
- TabIndex = 25
- Top = 3600
- Width = 2895
- End
- Begin Label LblUnitCost
- BackColor = &H00E0FFFF&
- Caption = "Unit Cost ="
- Height = 255
- Left = 2760
- TabIndex = 24
- Top = 3600
- Width = 2775
- End
- Begin Label LblTotalCost
- BackColor = &H00E0FFFF&
- Caption = "Total Cost ="
- Height = 255
- Left = 120
- TabIndex = 23
- Top = 3600
- Width = 2535
- End
- Begin Label LblIngCost
- BackColor = &H00E0FFFF&
- Height = 255
- Left = 7920
- TabIndex = 21
- Top = 1560
- Width = 735
- End
- Begin Label LblIngUnitDesc
- BackColor = &H00E0FFFF&
- Height = 255
- Left = 6600
- TabIndex = 20
- Top = 1560
- Width = 1095
- End
- Begin Label LblIngDesc
- BackColor = &H00E0FFFF&
- Height = 255
- Left = 2400
- TabIndex = 18
- Top = 1560
- Width = 3015
- End
- Begin Label LblHeadings
- BackColor = &H00E0FFFF&
- Caption = "V# &Ingredient# Description # Units Cost"
- Height = 255
- Left = 240
- TabIndex = 16
- Top = 1080
- Width = 8415
- End
- Begin Label LblLife
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "&Life:"
- Height = 255
- Left = 7320
- TabIndex = 14
- Top = 720
- Width = 495
- End
- Begin Label LblMaintCode
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "&Maint Code:"
- Height = 255
- Left = 5040
- TabIndex = 12
- Top = 720
- Width = 1095
- End
- Begin Label LblTarget
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "&Target %:"
- Height = 255
- Left = 3240
- TabIndex = 10
- Top = 720
- Width = 855
- End
- Begin Label LblYields
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "&Yields:"
- Height = 255
- Left = 1800
- TabIndex = 8
- Top = 720
- Width = 615
- End
- Begin Label LblRetail
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "&Retail:"
- Height = 255
- Left = 120
- TabIndex = 6
- Top = 720
- Width = 615
- End
- Begin Label LblDesc
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "D&escription:"
- Height = 255
- Left = 2280
- TabIndex = 2
- Top = 240
- Width = 1095
- End
- Begin Label LblKey
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "Recipe &Key:"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 1095
- End
- Begin Label LblGroup
- Alignment = 1 'Right Justify
- BackColor = &H00E0FFFF&
- Caption = "&Group:"
- Height = 255
- Left = 7080
- TabIndex = 4
- Top = 120
- Width = 735
- End
- '*************************************************************
- '* Form Name: RecipMnt *
- '* Performs file maintenance to Recipe file. *
- '*************************************************************
- Dim EntryMode As String * 1
- Dim FieldError As Integer
- Dim DetailSaved As Integer
- Dim SkipScreenUpdate As Integer
- Sub CalculateTotals ()
- SkipScreenUpdate = True
- On Local Error GoTo CalcError
- SaveGridRow% = Grid1.Row
- SaveGridCol% = Grid1.Col
- TotalCost@ = 0
- Grid1.Col = 4
- For I% = 0 To Grid1.Rows - 2
- Grid1.Row = I%
- TotalCost@ = TotalCost@ + Val(Grid1.Text)
- Next I%
- LblTotalCost.Caption = "Total Cost = " + Format$(TotalCost@, "###0.0000")
- UnitCost@ = TotalCost@ / Val(TxtYields.Text)
- LblUnitCost.Caption = "Unit Cost = " + Format$(UnitCost@, "###0.0000")
- Retail@ = Val(TxtRetail.Text)
- ProfitMargin@ = ((Retail@ - UnitCost@) / Retail@) * 100
- LblProfitMargin.Caption = "Profit Margin = " + Format$(ProfitMargin@, "##0.00")
- Grid1.Row = SaveGridRow%
- Grid1.Col = SaveGridCol%
- SkipScreenUpdate = False
- Grid1_RowColChange
- Exit Sub
- CalcError:
- Resume CalcErrorEnd
- CalcErrorEnd:
- LblTotalCost.Caption = "Total Cost = "
- LblUnitCost.Caption = "Unit Cost = "
- LblProfitMargin.Caption = "Profit Margin = "
- SkipScreenUpdate = False
- Grid1_RowColChange
- End Sub
- Sub ClearAllFields ()
- EntryMode = "N"
- TxtKey.Text = ""
- ClearDataFields
- TxtKey.SetFocus
- SetCmdFlags
- LblTotalCost.Caption = "Total Cost = "
- LblUnitCost.Caption = "Unit Cost = "
- LblProfitMargin.Caption = "Profit Margin = "
- End Sub
- Sub ClearDataFields ()
- Cls
- SkipScreenUpdate = True
- TxtDesc.Text = ""
- TxtGroup.Text = ""
- TxtRetail.Text = ""
- TxtYields.Text = ""
- TxtTarget.Text = ""
- TxtMaintCode.Text = ""
- TxtLife.Text = ""
- TxtIngKey.Text = ""
- TxtUnits.Text = ""
- LblIngDesc.Caption = ""
- LblIngUnitDesc.Caption = ""
- LblIngCost.Caption = ""
- T1% = Grid1.Rows - 2
- For I% = 0 To T1%
- Grid1.RemoveItem 0
- Next I%
- For I% = 0 To 4
- Grid1.Col = I%
- Grid1.Text = ""
- Next I%
- SkipScreenUpdate = False
- Grid1_RowColChange
- End Sub
- Sub CmdAdd_Click ()
- ErrorCheckFields
- MoveFieldsToRecord
- If Not FieldError Then
- WriteRecipe
- Select Case RecipeSt%
- Case 0
- ClearAllFields
- EndTransaction
- Case 3
- MsgRecipeNotOpen
- Case 5
- Msg$ = "Recipe already on file."
- T1% = MsgBox(Msg$, 0, "Note")
- TxtDesc.SetFocus
- Case Else
- MsgUnknownRecipeError
- End Select
- End If
- End Sub
- Sub CmdCancel_Click ()
- If ActiveTransaction Then
- AbortTransaction
- End If
- ClearAllFields
- End Sub
- Sub CmdClose_Click ()
- If EntryMode = "C" Then
- Msg$ = "Record has not been updated." + Chr$(13)
- Msg$ = "Do you want to update the record?"
- TI% = MsgBox(Msg$, 260, "Message")
- End If
- If TI% <> 6 Then
- Unload RecipMnt
- End If
- End Sub
- Sub CmdDelete_Click ()
- Msg$ = "Are you sure?"
- TI% = MsgBox(Msg$, 260, "Delete?")
- If TI% = 6 Then
- DeleteRecipeDetail
- DeleteRecipe
- SalesMixRec.RecNo = RecipeRec.RecNo
- ReadSalesMix
- DeleteSalesMix
- EndTransaction
- Select Case RecipeSt%
- Case 0
- ClearAllFields
- Case 8
- Msg$ = "Record must be found before you can delete."
- Beep
- T1% = MsgBox(Msg$, 0, "Warning!")
- Case 80
- Msg$ = "This record updated since read. Reread and try again."
- Beep
- T1% = MsgBox(Msg$, 0, "Not Deleted!")
- Case Else
- Msg$ = "Recipe not deleted. Status = " + Str$(RecipeSt%)
- Beep
- T1% = MsgBox(Msg$, 0, "Warning!")
- End Select
- End If
- End Sub
- Sub CmdNext_Click ()
- Screen.MousePointer = 11
- If ActiveTransaction Then
- AbortTransaction
- End If
- ClearDataFields
- NextRecipe
- Select Case RecipeSt%
- Case 0
- DisplayDataFields
- ReadAllRecipeDet
- BeginTransaction
- Case 3
- Screen.MousePointer = 0
- MsgRecipeNotOpen
- Case 8
- FirstRecipe
- If RecipeSt% <> 0 Then
- Screen.MousePointer = 0
- MsgUnknownRecipeError
- Else
- DisplayDataFields
- ReadAllRecipeDet
- BeginTransaction
- End If
- Case 9
- Screen.MousePointer = 0
- ClearAllFields
- Msg$ = "End of Recipe file."
- T1% = MsgBox(Msg$, 0, "Note")
- Case Else
- Screen.MousePointer = 0
- MsgUnknownRecipeError
- End Select
- SetCmdFlags
- Screen.MousePointer = 0
- End Sub
- Sub CmdPrevious_Click ()
- Screen.MousePointer = 11
- If ActiveTransaction Then
- AbortTransaction
- End If
- ClearDataFields
- PreviousRecipe
- Select Case RecipeSt%
- Case 0
- DisplayDataFields
- ReadAllRecipeDet
- BeginTransaction
- Case 3
- Screen.MousePointer = 0
- MsgRecipeNotOpen
- Case 8
- FirstRecipe
- If RecipeSt% <> 0 Then
- Screen.MousePointer = 0
- MsgUnknownRecipeError
- Else
- DisplayDataFields
- ReadAllRecipeDet
- BeginTransaction
- End If
- Case 9
- Screen.MousePointer = 0
- ClearAllFields
- Msg$ = "Beginning of Recipe file."
- T1% = MsgBox(Msg$, 0, "Note")
- Case Else
- Screen.MousePointer = 0
- MsgUnknownRecipeError
- End Select
- Screen.MousePointer = 0
- SetCmdFlags
- End Sub
- Sub CmdRemove_Click ()
- If Grid1.Rows > 1 Then
- If Grid1.Row <> Grid1.Rows - 1 Then
- RecipeDetRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- ReadRecipeDet
- If RecipeDetSt% <> 0 Then
- MsgUnknownRecipeDetError
- Else
- DeleteRecipeDet
- Grid1.RemoveItem Grid1.Row
- Grid1.Col = 0
- TxtIngKey.Text = Grid1.Text
- Grid1.Col = 1
- LblIngDesc.Caption = Grid1.Text
- Grid1.Col = 2
- TxtUnits.Text = Grid1.Text
- Grid1.Col = 3
- LblIngUnitDesc.Caption = Grid1.Text
- Grid1.Col = 4
- LblIngCost.Caption = Grid1.Text
- CalculateTotals
- End If
- End If
- End If
- TxtIngKey.SetFocus
- End Sub
- Sub CmdUpdate_Click ()
- EntryMode = "C"
- ErrorCheckFields
- If Not FieldError Then
- MoveFieldsToRecord
- UpdateRecipe
- Select Case RecipeSt%
- Case 0
- EntryMode = "N"
- ClearAllFields
- EndTransaction
- Case 3
- MsgRecipeNotOpen
- Case 5
- Msg$ = "Recipe duplicate on file."
- T1% = MsgBox(Msg$, 0, "Note")
- Case 8
- Msg$ = "Update only works on found records."
- T1% = MsgBox(Msg$, 0, "Note")
- Case 80
- Msg$ = "This record updated since read. Reread and try again."
- T1% = MsgBox(Msg$, 0, "Warning!")
- Case Else
- MsgUnknownRecipeError
- End Select
- End If
- End Sub
- Sub DeleteRecipeDetail ()
- RecipeDetRec.RecDetKey = RecipeRec.RecNo + String$(15, "0")
- GetGERecipeDet
- If RecipeDetSt% = 9 Then
- Exit Sub
- End If
- If RecipeDetSt% <> 0 Then
- MsgUnknownRecipeDetError
- End If
- Do Until RecipeDetSt% <> 0 Or RecipeDetRec.RecDetKey > RecipeRec.RecNo + String$(15, "Z")
- DeleteRecipeDet
- NextRecipeDet
- Loop
- End Sub
- Sub DisplayDataFields ()
- SkipScreenUpdate = True
- RecipeSaveRec = RecipeRec
- TxtKey.Text = RecipeRec.RecNo
- TxtDesc.Text = RecipeRec.RecDesc
- TxtGroup.Text = RecipeRec.RecGroup
- TxtRetail.Text = Format$((RecipeRec.RecRetail / 100), "###.00")
- TxtYields.Text = Format$(RecipeRec.Servings, "##0")
- TxtTarget.Text = Format$((RecipeRec.TargetProfit * 100), "###.00")
- TxtMaintCode.Text = RecipeRec.MaintenanceCode
- TxtLife.Text = Format$(RecipeRec.ShelfLifeDays, "#0")
- TxtRetail.SetFocus
- EntryMode = "U"
- SkipScreenUpdate = False
- End Sub
- Sub ErrorCheckFields ()
- FieldError = False
- If LTrim$(RTrim$(TxtKey.Text)) = "" Then
- Msg$ = "Recipe number is required."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtKey.SetFocus
- Exit Sub
- End If
- If LTrim$(RTrim$(TxtDesc.Text)) = "" Then
- Msg$ = "Description is required."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtDesc.SetFocus
- Exit Sub
- End If
- If LTrim$(RTrim$(TxtGroup.Text)) = "" Then
- Msg$ = "Recipe group is required."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtGroup.SetFocus
- Exit Sub
- End If
- RecGroupRec.RecGroup = LTrim$(RTrim$(TxtGroup.Text))
- ReadRecGroup
- If RecGroupSt% <> 0 Then
- Msg$ = "Recipe group is not valid."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtGroup.SetFocus
- Exit Sub
- End If
- If LTrim$(RTrim$(TxtRetail.Text)) = "" Then
- Msg$ = "You must have a retail."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtRetail.SetFocus
- Exit Sub
- End If
- If LTrim$(RTrim$(TxtYields.Text)) = "" Then
- Msg$ = "You must servings per recipe."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtYields.SetFocus
- Exit Sub
- End If
- If LTrim$(RTrim$(TxtTarget.Text)) = "" Then
- Msg$ = "You must enter a target gross profit."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtTarget.SetFocus
- Exit Sub
- Else
- Test@ = Val(TxtTarget.Text)
- If Test@ < .01 Or Test@ > 100# Then
- Beep
- Msg$ = "Target profit must be between .01 and 100.00"
- MsgBox Msg$, 0, "Warning"
- FieldError = True
- TxtTarget.SetFocus
- Exit Sub
- End If
- End If
- If LTrim$(RTrim$(TxtMaintCode.Text)) = "" Then
- Msg$ = "You must enter a maintenance code."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtMaintCode.SetFocus
- Exit Sub
- End If
- Select Case UCase$(LTrim$(RTrim$(TxtMaintCode.Text)))
- Case "N", "D", "M"
- Case Else
- Msg$ = "Maint Code must be:" + Chr$(10)
- Msg$ = Msg$ + "N - Round to nine" + Chr$(10)
- Msg$ = Msg$ + "D - Round to dollar 99" + Chr$(10)
- Msg$ = Msg$ + "M - Manual calculation"
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtMaintCode.SetFocus
- Exit Sub
- End Select
- If LTrim$(RTrim$(TxtLife.Text)) = "" Then
- Msg$ = "You must enter a shelf life."
- T1% = MsgBox(Msg$, 0, "Note")
- FieldError = True
- TxtLife.SetFocus
- Exit Sub
- End If
- End Sub
- Sub Form_Activate ()
- RecipeRec.RecNo = TxtKey.Text + String$(6 - Len(TxtKey.Text), " ")
- ReadRecipe
- IngredientRec.IngKey = TxtIngKey.Text + String$(18 - Len(TxtIngKey.Text), " ")
- RecipeDetRec.RecDetKey = RecipeRec.RecNo + IngredientRec.IngKey
- ReadRecipeDet
- End Sub
- Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- End Sub
- Sub Form_Load ()
- RecipMnt.Top = DeliMain.Top
- RecipMnt.Left = DeliMain.Left
- RecipMnt.Height = 4905
- RecipMnt.Width = 8985
- EntryMode = "N"
- SkipScreenUpdate = False
- Grid1.ColWidth(0) = 2150
- Grid1.ColWidth(1) = 3225
- Grid1.ColWidth(2) = 950
- Grid1.ColAlignment(2) = 1
- Grid1.ColWidth(3) = 1200
- Grid1.ColWidth(4) = 925
- Grid1.ColAlignment(4) = 1
- Grid1.Row = 0
- Grid1.RowHeight(0) = Grid1.Height / 6.47
- Grid1_RowColChange
- Screen.MousePointer = 0
- End Sub
- Sub Form_Unload (Cancel As Integer)
- If ActiveTransaction Then
- AbortTransaction
- End If
- End Sub
- Sub Grid1_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_UP Then
- ScrollGridUp
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- KeyCode = 0
- ElseIf KeyCode = KEY_DOWN Then
- ScrollGridDown
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- KeyCode = 0
- End If
- End Sub
- Sub Grid1_RowColChange ()
- If Not SkipScreenUpdate Then
- Grid1.SelStartCol = 0
- Grid1.SelEndCol = 4
- Grid1.SelStartRow = Grid1.Row
- Grid1.SelEndRow = Grid1.Row
- End If
- End Sub
- Sub MoveFieldsToRecord ()
- RecipeRec.RecNo = TxtKey.Text + String$(6 - Len(TxtKey.Text), " ")
- RecipeRec.RecDesc = TxtDesc.Text
- RecipeRec.RecGroup = TxtGroup.Text
- RecipeRec.RecRetail = Val(TxtRetail.Text) * 100
- RecipeRec.Servings = Val(TxtYields.Text)
- RecipeRec.TargetProfit = Val(TxtTarget.Text) / 100
- RecipeRec.MaintenanceCode = TxtMaintCode.Text
- RecipeRec.ShelfLifeDays = Val(TxtLife.Text)
- End Sub
- Sub ReadAllRecipeDet ()
- SkipScreenUpdate = True
- DetailSaved = False
- RecipeDetRec.RecDetKey = RecipeRec.RecNo + String$(15, "0")
- GetGERecipeDet
- If RecipeDetSt% = 9 Then
- Exit Sub
- End If
- If RecipeDetSt% <> 0 Then
- MsgUnknownRecipeDetError
- End If
- Do Until RecipeDetSt% <> 0 Or RecipeDetRec.RecDetKey > RecipeRec.RecNo + String$(15, "Z")
- IngredientRec.IngKey = Mid$(RecipeDetRec.RecDetKey, 7, 15)
- ReadIngredient
- If IngredientSt% = 0 Then
- GoSub AddToGrid
- End If
- NextRecipeDet
- Loop
- SkipScreenUpdate = False
- Grid1_RowColChange
- CalculateTotals
- Exit Sub
- AddToGrid:
- If Grid1.Row = Grid1.Rows - 1 Then
- Grid1.AddItem "", Grid1.Rows
- Grid1.RowHeight(Grid1.Row + 1) = Grid1.Height / 6.47
- End If
- Grid1.Col = 0
- Grid1.Text = IngredientRec.IngKey
- Grid1.Col = 1
- Grid1.Text = RTrim$(IngredientRec.IngDesc)
- Grid1.Col = 2
- Grid1.Text = Format$(RecipeDetRec.RecDetQty, "##0.00")
- Grid1.Col = 3
- Grid1.Text = RTrim$(IngredientRec.IngUnitDesc)
- Cost& = IngredientRec.IngCaseCost / IngredientRec.IngUnitsPerCase
- Cost& = Cost& * RecipeDetRec.RecDetQty
- LblIngCost.Caption = Format$(Cost& / 10000, "###.0000")
- Grid1.Col = 4
- Grid1.Text = LblIngCost.Caption
- ScrollGridDown
- Return
- End Sub
- Sub ScrollGridDown ()
- If Grid1.Row < Grid1.Rows - 1 Then
- Grid1.Row = Grid1.Row + 1
- If Grid1.Rows > 6 Then
- If Grid1.Row > Grid1.Rows - 3 Then
- Grid1.TopRow = Grid1.Rows - 5
- Else
- If Grid1.Row < 3 Then
- Grid1.TopRow = 0
- Else
- Grid1.TopRow = Grid1.Row - 3
- End If
- End If
- End If
- End If
- Grid1.Col = 0
- TxtIngKey.Text = RTrim$(Grid1.Text)
- Grid1.Col = 1
- LblIngDesc.Caption = Grid1.Text
- Grid1.Col = 2
- TxtUnits.Text = Grid1.Text
- Grid1.Col = 3
- LblIngUnitDesc.Caption = Grid1.Text
- Grid1.Col = 4
- LblIngCost.Caption = Grid1.Text
- TxtIngKey.SelStart = 0
- TxtIngKey.SelLength = Len(TxtIngKey.Text)
- Grid1.Col = 0
- End Sub
- Sub ScrollGridUp ()
- If Grid1.Row > 0 Then
- Grid1.Row = Grid1.Row - 1
- If Grid1.Rows > 6 Then
- If Grid1.Row < 3 Then
- Grid1.TopRow = 0
- Else
- Grid1.TopRow = Grid1.Row - 3
- End If
- End If
- End If
- Grid1.Col = 0
- TxtIngKey.Text = RTrim$(Grid1.Text)
- Grid1.Col = 1
- LblIngDesc.Caption = Grid1.Text
- Grid1.Col = 2
- TxtUnits.Text = Grid1.Text
- Grid1.Col = 3
- LblIngUnitDesc.Caption = Grid1.Text
- Grid1.Col = 4
- LblIngCost.Caption = Grid1.Text
- Grid1.Col = 0
- TxtIngKey.SelStart = 0
- TxtIngKey.SelLength = Len(TxtIngKey.Text)
- End Sub
- Sub SetCmdFlags ()
- If Not SkipScreenUpdate Then
- Select Case EntryMode
- Case "N"
- CmdPrevious.Enabled = True
- CmdNext.Enabled = True
- CmdCancel.Enabled = False
- CmdAdd.Enabled = True
- CmdUpdate.Enabled = False
- CmdDelete.Enabled = False
- Case "U"
- CmdPrevious.Enabled = True
- CmdNext.Enabled = True
- CmdCancel.Enabled = False
- CmdAdd.Enabled = False
- CmdUpdate.Enabled = True
- CmdDelete.Enabled = True
- Case "C"
- CmdPrevious.Enabled = True
- CmdNext.Enabled = True
- CmdCancel.Enabled = True
- CmdAdd.Enabled = False
- CmdUpdate.Enabled = True
- CmdDelete.Enabled = False
- Case Else
- Msg$ = "Undefined Entry Mode Flag - " + EntryMode + "."
- T1% = MsgBox(Msg$, 0, "Warning!")
- End Select
- End If
- End Sub
- Sub TxtDesc_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtDesc_GotFocus ()
- TxtDesc.SelStart = 0
- TxtDesc.SelLength = Len(TxtDesc.Text)
- End Sub
- Sub TxtDesc_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtDesc_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- TxtGroup.SetFocus
- ElseIf Chr$(KeyAscii) = "-" Then
- KeyAscii = 0
- Beep
- Else
- StrKP TxtDesc, 30, KeyAscii
- KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
- End If
- End Sub
- Sub TxtGroup_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtGroup_GotFocus ()
- TxtGroup.SelStart = 0
- TxtGroup.SelLength = Len(TxtGroup.Text)
- End Sub
- Sub TxtGroup_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtGroup_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- TxtRetail.SetFocus
- Else
- IntKP TxtGroup, 4, KeyAscii
- End If
- End Sub
- Sub TxtGroup_LostFocus ()
- If TxtGroup.Text = "" Then
- If RecipeSaveRec.RecGroup <> " " Then
- TxtGroup.Text = RecipeSaveRec.RecGroup
- End If
- End If
- If TxtGroup.Text <> "" Then
- RecGroupRec.RecGroup = String$(4 - Len(TxtGroup.Text), "0") + TxtGroup.Text
- TxtGroup.Text = RecGroupRec.RecGroup
- ReadRecGroup
- Select Case RecGroupSt%
- Case 0
- Case 3
- MsgRecGroupNotOpen
- Case 4
- MsgRecGroupNotFound
- TxtGroup.SetFocus
- Case Else
- MsgUnknownRecGroupError
- End Select
- End If
- End Sub
- Sub TxtIngKey_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtIngKey_GotFocus ()
- TxtIngKey.SelStart = 0
- TxtIngKey.SelLength = Len(TxtIngKey.Text)
- Grid1.Col = 0
- End Sub
- Sub TxtIngKey_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_UP Then
- ScrollGridUp
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- KeyCode = 0
- ElseIf KeyCode = KEY_DOWN Then
- ScrollGridDown
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- KeyCode = 0
- End If
- End Sub
- Sub TxtIngKey_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- If TxtIngKey.Text <> "" Then
- IngredientRec.IngKey = TxtIngKey.Text + String$(18 - Len(TxtIngKey.Text), " ")
- TxtIngKey.Text = IngredientRec.IngKey
- ReadIngredient
- Select Case IngredientSt%
- Case 0
- LblIngDesc.Caption = IngredientRec.IngDesc
- LblIngUnitDesc.Caption = IngredientRec.IngUnitDesc
- TxtUnits.SetFocus
- Case 3
- MsgIngredientNotOpen
- TxtUnits.SetFocus
- Case 4
- MsgIngredientNotFound
- TxtIngKey.SetFocus
- TxtIngKey.SelStart = 0
- TxtIngKey.SelLength = Len(TxtIngKey.Text)
- Grid1.Col = 0
- Case Else
- MsgUnknownIngredientError
- TxtUnits.SetFocus
- End Select
- KeyAscii = 0
- Else
- Msg$ = "Ingredient number is required."
- T1% = MsgBox(Msg$, 0, "Note")
- KeyAscii = 0
- TxtIngKey.SetFocus
- End If
- Else
- StrKP TxtIngKey, 18, KeyAscii
- KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
- End If
- End Sub
- Sub TxtKey_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtKey_GotFocus ()
- ClearAllFields
- If ActiveTransaction Then
- AbortTransaction
- End If
- End Sub
- Sub TxtKey_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtKey_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- If TxtKey.Text <> "" Then
- Screen.MousePointer = 11
- BeginTransaction
- KeyAscii = 0
- EntryMode = "N"
- RecipeRec.RecNo = TxtKey.Text + String$(6 - Len(TxtKey.Text), " ")
- ReadRecipe
- Select Case RecipeSt%
- Case 0
- RecipeSaveRec = RecipeRec
- DisplayDataFields
- ReadAllRecipeDet
- Case 3
- Screen.MousePointer = 0
- MsgRecipeNotOpen
- Case 4
- RecipeRec.UpdateFlag = " "
- ClearDataFields
- TxtDesc.SetFocus
- Case Else
- Screen.MousePointer = 0
- MsgUnknownRecipeError
- End Select
- SetCmdFlags
- Screen.MousePointer = 0
- Else
- TxtKey.SetFocus
- End If
- Else
- UCStrKP TxtKey, 6, KeyAscii
- End If
- End Sub
- Sub TxtLife_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtLife_GotFocus ()
- TxtLife.SelStart = 0
- TxtLife.SelLength = Len(TxtLife.Text)
- End Sub
- Sub TxtLife_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtLife_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- TxtIngKey.SetFocus
- Else
- IntKP TxtLife, 2, KeyAscii
- End If
- End Sub
- Sub TxtMaintCode_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtMaintCode_GotFocus ()
- TxtMaintCode.SelStart = 0
- TxtMaintCode.SelLength = Len(TxtMaintCode.Text)
- End Sub
- Sub TxtMaintCode_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtMaintCode_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- Select Case TxtMaintCode.Text
- Case "N", "D", "M" 'Round to nine
- TxtLife.SetFocus
- Case Else
- Msg$ = "Maint Code must be:" + Chr$(10)
- Msg$ = Msg$ + "N - Round to nine" + Chr$(10)
- Msg$ = Msg$ + "D - Round to dollar 99" + Chr$(10)
- Msg$ = Msg$ + "M - Manual calculation"
- T1% = MsgBox(Msg$, 0, "Note!")
- TxtMaintCode.Text = ""
- End Select
- KeyAscii = 0
- Else
- StrKP TxtMaintCode, 1, KeyAscii
- KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
- End If
- End Sub
- Sub TxtRetail_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtRetail_GotFocus ()
- TxtRetail.SelStart = 0
- TxtRetail.SelLength = Len(TxtRetail.Text)
- End Sub
- Sub TxtRetail_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtRetail_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- CalculateTotals
- If CmdUpdate.Enabled = True Then
- CmdUpdate.SetFocus
- If CInt(Val(TxtRetail.Text) * 100) <> RecipeSaveRec.RecRetail Then
- RecipeRec.UpdateFlag = "C"
- Else
- RecipeRec.UpdateFlag = " "
- End If
- Else
- RecipeRec.UpdateFlag = "A"
- TxtYields.SetFocus
- End If
- Else
- Curr2KP TxtRetail, 5, KeyAscii
- End If
- End Sub
- Sub TxtTarget_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtTarget_GotFocus ()
- TxtTarget.SelStart = 0
- TxtTarget.SelLength = Len(TxtTarget.Text)
- End Sub
- Sub TxtTarget_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtTarget_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- TxtMaintCode.SetFocus
- Else
- Curr2KP TxtTarget, 6, KeyAscii
- End If
- End Sub
- Sub TxtTarget_LostFocus ()
- t@ = Curr2LF(TxtTarget, .01, 100)
- End Sub
- Sub TxtUnits_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtUnits_GotFocus ()
- TxtUnits.SelStart = 0
- TxtUnits.SelLength = Len(TxtUnits.Text)
- Grid1.Col = 2
- End Sub
- Sub TxtUnits_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_UP Then
- ScrollGridUp
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- KeyCode = 0
- TxtIngKey.SetFocus
- ElseIf KeyCode = KEY_DOWN Then
- ScrollGridDown
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- KeyCode = 0
- TxtIngKey.SetFocus
- End If
- End Sub
- Sub TxtUnits_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- If TxtUnits.Text <> "" Then
- If DetailSaved Then
- RecipeDetRec.RecDetKey = RecipeDetSaveRec.RecDetKey
- ReadRecipeDet
- DeleteRecipeDet
- End If
- RecipeDetRec.RecDetKey = RecipeRec.RecNo + IngredientRec.IngKey
- RecipeDetRec.RecDetQty = Val(TxtUnits.Text)
- WriteRecipeDet
- Select Case RecipeDetSt%
- Case 0
- KeyAscii = 0
- TxtIngKey.SetFocus
- If Grid1.Row = Grid1.Rows - 1 Then
- Grid1.AddItem "", Grid1.Rows
- Grid1.RowHeight(Grid1.Row + 1) = Grid1.Height / 6.47
- End If
- Grid1.Col = 0
- Grid1.Text = TxtIngKey.Text
- Grid1.Col = 1
- Grid1.Text = RTrim$(IngredientRec.IngDesc)
- Grid1.Col = 2
- Grid1.Text = TxtUnits.Text
- Grid1.Col = 3
- Grid1.Text = RTrim$(IngredientRec.IngUnitDesc)
- Cost& = IngredientRec.IngCaseCost / IngredientRec.IngUnitsPerCase
- Cost& = Cost& * Val(TxtUnits.Text)
- LblIngCost.Caption = Format$(Cost& / 10000, "###.0000")
- Grid1.Col = 4
- Grid1.Text = LblIngCost.Caption
- ScrollGridDown
- If Grid1.Text <> "" Then
- Grid1.Col = 0
- RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
- RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
- DetailSaved = True
- Else
- DetailSaved = False
- End If
- CalculateTotals
- Case 5
- MsgRecipeDetDuplicate
- TxtUnits.Text = ""
- TxtIngKey.SetFocus
- Case Else
- MsgUnknownRecipeDetError
- End Select
- Else
- Msg$ = "Quantity is required."
- T1% = MsgBox(Msg$, 0, "Note")
- KeyAscii = 0
- TxtUnits.SetFocus
- End If
- Else
- Curr2KP TxtUnits, 6, KeyAscii
- End If
- End Sub
- Sub TxtYields_Change ()
- If EntryMode = "U" Then
- EntryMode = "C"
- SetCmdFlags
- End If
- End Sub
- Sub TxtYields_GotFocus ()
- TxtYields.SelStart = 0
- TxtYields.SelLength = Len(TxtYields.Text)
- End Sub
- Sub TxtYields_KeyDown (KeyCode As Integer, Shift As Integer)
- If KeyCode = KEY_F4 Then ' Display key combinations.
- If TxtDesc.Text <> "" Then
- TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
- TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
- End If
- End If
- If KeyCode = KEY_PAGE_UP Then
- CmdPrevious_Click
- End If
- If KeyCode = KEY_PAGE_DOWN Then
- CmdNext_Click
- End If
- End Sub
- Sub TxtYields_KeyPress (KeyAscii As Integer)
- If KeyAscii = 13 Then
- KeyAscii = 0
- TxtTarget.SetFocus
- CalculateTotals
- Else
- IntKP TxtYields, 3, KeyAscii
- End If
- End Sub
-